package com.example.shop.utils;

import lombok.Data;

/**
 * 通用返回结果
 */
@Data
public class Result<T> {
	private Integer code; // 响应编码
	private String msg; // 响应提示消息
	private T result; // 响应内容

	public Result() {

	}

	public Result(Integer code, String msg, T result) {
		this.code = code;
		this.msg = msg;
		this.result = result;
	}

	@Override
	public String toString() {
		return "Result [code=" + code + ", msg=" + msg + ", result=" + result + "]";
	}

	public Integer getCode() {
		return code;
	}

	public void setCode(Integer code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public T getResult() {
		return result;
	}

	public void setResult(T result) {
		this.result = result;
	}

	public static Result success(Object result) {
		return new Result<>(10000,"success",result);
	}
	public static Result fail(Object result) {
		return new Result<>(10001,"fail",result);
	}
}
